package lion.framework.core.web.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.framework.core.web.views.IView;
import lion.framework.core.web.views.ViewFactory;

/**
 * 视图类型处理
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年3月18日
 */
@AnnoProcessor(ViewType.class)
public class ViewTypeProcessor implements IAnnotationProcessor {

	@SuppressWarnings("unchecked")
	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_TARGET);
		if (!ViewType.class.isAssignableFrom(anno.getClass())) { return; }

		ViewType vt = (ViewType) anno;
		ViewFactory.regist(vt.value(), (Class<? extends IView>) clazz);
	}
}
